package com.lovi.category.controller;

import com.lovi.category.service.CategoryService;
import com.lovi.param.PageParam;
import com.lovi.pojo.Category;
import com.lovi.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class AdminCategoryController {
    @Autowired
    private CategoryService categoryService;

    @PostMapping("/category/admin/list")
    R adminPageList(@RequestBody PageParam pageParam){

        return categoryService.listPage(pageParam);
    }

    @PostMapping("/category/admin/save")
    R adminSave(@RequestBody Category category){
        return categoryService.save(category);
    }

    @PostMapping("/category/admin/remove")
    R adminRemove(@RequestBody Integer categoryId){
        return categoryService.remove(categoryId);
    }

    @PostMapping("/category/admin/update")
    R adminUpdate(@RequestBody Category category){
        return categoryService.update(category);
    }
}
